package com.vpen.picupload.entity;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;

/**
 * @version: 1.0
 * @author: Vpen
 * @date: 2021/9/5 8:30
 * @content:
 */
@Data
@Accessors(chain = true)
@ApiModel("请求类")
public class BeanReq {
    private Integer age;
    private String name;
    private List<Integer> city;
    private User user;
    /**
     * 描述: 请求类---->json
     * 实体类---->数据库
     *
     * @return com.vpen.picupload.entity.DatabaseBean
     * @author 韦鹏
     * @name covert
     * @date 2021/9/5 10:04
     **/
    public DatabaseBean covert() {
        DatabaseBean entity = new DatabaseBean();
        String city = JSONUtil.toJsonStr(this.getCity());
        String user = JSONUtil.toJsonStr(this.getUser());
        BeanUtil.copyProperties(this, entity);
        return entity.setCity(city).setUser(user);
    }
}
